Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/prepare json yaml files #5

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ericearl
Copy link
Member

  • Implemented functionality to generate both JSON and YAML files for derivatives in a BIDS dataset, ensuring compatibility with multiple data types. (Pooja's script was missing this)
  • Fixed bugs in JSON file generation for input data, ensuring accurate file parsing and content preparation. (Pooja's script generated empty JSON files for inputs; I resolved this)
  • Completed the addition of -s (source) and -d (destination) command-line arguments to allow users to specify custom input and output paths. (Pooja's TODO—completed by me)
  • Refactored the script extensively to improve code readability and maintainability.

How to Run:

cd json_yaml_files
python3 prepare_file.py -s <path_to_bids_data> -d <desination_path_for_output_files>

pbbaba and others added 9 commits August 1, 2024 10:42
Added a small additional description to the ArgumentParser.
Implemented functionality to generate both JSON and YAML files for derivatives in a BIDS dataset, ensuring compatibility with multiple data types. (Pooja's script was missing this)
Fixed bugs in JSON file generation for input data, ensuring accurate file parsing and content preparation. (Pooja's script generated empty JSON files for inputs; I resolved this)
Completed the addition of -s (source) and -d (destination) command-line arguments to allow users to specify custom input and output paths. (Pooja's TODO—completed by me)
Refactored the script extensively to improve code readability and maintainability.
How to Run:
cd json_yaml_files
python3 prepare_file.py -s <path_to_bids_data> -d <desination_path_for_output_files>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines +61 to +62
self.json_dir = self.destination_path / 'prepared_jsons'
self.yaml_dir = self.destination_path / 'prepared_yamls'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSONs and YAMLs are pairs of files for upload. Was there a reason to separate them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intresting. Pooja's code did seperate files into seperate folder. Let me go ahead and output the files in single folder.


def prepare_json_contents(self, file_name, files):
json_contents = {}
_, X, _, _ = self.extract_file_name_components(file_name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the A, Y, and Z matches being thrown away?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the change is that we are not using A, Y, or Z in the function. Previously, Pooja's code used X and Y to extract files, but this extraction was redundant since the files had already been extracted using .get in the for loop within the run() function. To address this, I passed the files as an argument to the prepare_json_contents function, which wasn’t done previously.

This change improves runtime efficiency by avoiding redundant file extraction.

}

for file_path in files:
sub_path = file_path[file_path.find(sub_path_prefix.get(X, '')):] if X in sub_path_prefix else file_path
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is hard to read. Please separate it out into an easier-to-understand multiple lines.


def run(self):
scopes = {
'raw': 'inputs',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"raw" is regularly called "rawdata" in BIDS.

Comment on lines +168 to +169
files = self.layout.get(
scope=x if x != 'inputs' else 'raw', datatype=y, return_type='file')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand this line into multiple lines for easier reading. Specifically:

x if x != 'inputs' else 'raw'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I will do that.

Girish-Anadv-07 and others added 2 commits December 17, 2024 10:27
Co-authored-by: Eric Earl <[email protected]>
Co-authored-by: Eric Earl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants